Michael Henning <drawoc@darkrefraction.com>
authorØyvind Kolås <pippin@gimp.org>
Tue, 13 Nov 2012 22:06:21 +0000 (23:06 +0100)
committerØyvind Kolås <pippin@gimp.org>
Tue, 13 Nov 2012 22:06:21 +0000 (23:06 +0100)
Clean up babl_process_chunks a bit.

babl/babl-fish-path.c

index 7c1a87bb6ba6a9348a4e68faae75a6753d16ff8e..f7ab32a3b1def5cb439eed73d72310240e37a393 100644 (file)
@@ -25,6 +25,8 @@
 #define BABL_HARD_MAX_PATH_LENGTH  8
 #define BABL_MAX_NAME_LEN          1024
 
+#define MIN(a, b) (((a) > (b)) ? (b) : (a))
+
 #define NUM_TEST_PIXELS            3072
 
 int   babl_in_fish_path = 0;
@@ -407,7 +409,7 @@ babl_process_chunks (const Babl *cbabl,
         source_bpp = babl_source->type.bits / 8;
         break;
       default:
-        fprintf (stderr, "=eeek{%i}\n", babl_source->instance.class_type - BABL_MAGIC);
+        babl_log ("=eeek{%i}\n", babl_source->instance.class_type - BABL_MAGIC);
     }
 
   switch (babl_dest->instance.class_type)
@@ -419,7 +421,7 @@ babl_process_chunks (const Babl *cbabl,
         dest_bpp = babl_dest->type.bits / 8;
         break;
       default:
-        fprintf (stderr, "-eeek{%i}\n", babl_dest->instance.class_type - BABL_MAGIC);
+        babl_log ("-eeek{%i}\n", babl_dest->instance.class_type - BABL_MAGIC);
     }
 
   babl_assert (source_bpp);
@@ -427,14 +429,12 @@ babl_process_chunks (const Babl *cbabl,
 
   for (i = 0; i < n; i += MAX_BUFFER_SIZE)
     {
-      long c;
-      if (i + MAX_BUFFER_SIZE <= n)
-        c = MAX_BUFFER_SIZE;
-      else
-        c = n - i;
-
-      babl_process (cbabl, source + (i * source_bpp),
-                           destination + (i * dest_bpp), c);
+      long c = MIN (n - i, MAX_BUFFER_SIZE);
+
+      babl->fish.processings++;
+      babl->fish.pixels +=
+             babl_fish_process (babl, source + (i * source_bpp),
+                                destination + (i * dest_bpp), c);
     }
   return n;
 }